package bean;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.GenericGenerator;

@Entity
@Table(name="street")
@GenericGenerator(name="GENID", strategy="identity")
public class Street implements java.io.Serializable{
	@Id
	@Column(name="ID")
	//@GeneratedValue(strategy=GenerationType.IDENTITY)
	@GeneratedValue(generator="GENID")
	private Integer streetId;
	@Column(name="NAME")
	private String name;
	@ManyToOne
	@JoinColumn(name="DISTRICT_ID")
	@Cascade(value={CascadeType.ALL})
	@Fetch(FetchMode.SELECT)
	private District district;
	@OneToMany
	@JoinColumn(name="STREET_ID")
	@Cascade(value={CascadeType.ALL})
	private Set<House> houses = new HashSet<House>();
	
	public Street() {
		super();
	}
	public Integer getStreetId() {
		return streetId;
	}
	public void setStreetId(Integer streetId) {
		this.streetId = streetId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public District getDistrict() {
		return district;
	}
	public void setDistrict(District district) {
		this.district = district;
	}
	public Set<House> getHouses() {
		return houses;
	}
	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}
	@Override
	public String toString() {
		return "Street [streetId=" + streetId + ", name=" + name + ", district=" + district + ", houses=" + houses
				+ "]";
	}
}